package com.cysion.study.ui

import android.support.v7.widget.LinearLayoutManager
import com.cysion.other.color
import com.cysion.study.R
import com.cysion.study.adapter.POrderTeacherAdapter
import com.cysion.study.entity.ProcessLists
import com.cysion.study.helper.UserCache
import com.cysion.study.ktbox.Box.context
import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.base.ITEM_CLICK
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.ktbox.utils.darkTextTheme
import com.cysion.study.net.ApiClient
import com.cysion.study.uibox.bar.TopBar
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.widget.ShowToast
import com.cysion.targetfun._subscribe
import kotlinx.android.synthetic.main.activity_pwithdraw_detail.*

class PWithdrawDetailActivity :BaseActivity(){
    override fun getLayoutId(): Int {
        return R.layout.activity_pwithdraw_detail
    }

    private var id=""
    override fun initView() {
        id = intent.extras.getString("id")
        darkTextTheme(color(R.color.white))
        topbar.apply {
            setTitleBackColor(color(R.color.white))
            setTitle("提现详情")
            setOnTopBarClickListener { obj, pos ->
                if (pos == TopBar.Pos.LEFT) {
                    finish()
                }
            }
        }

    }

    override fun initData() {
        super.initData()
        getData()
    }
    private fun getData() {
        Alert.loading(self)
        ApiClient.api.getBalanceDetails(UserCache.token,id).compose(
            BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()

//                    tv_money.text=it.
                    tv_time.text="提现发起时间："+it.txCreateTime
                    tv_card.text="收款银行账号："+it.txBankCard
                    tv_bank.text="收款银行："+it.txBank
                    tv_bank_name.text="开户支行："+it.txAddress

                    dataList.clear()
                    dataList.addAll(it.processList)
                    mAdapter.notifyDataSetChanged()
                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)
                }
            }
    }

    //退款进度list
    private lateinit var mAdapter: POrderTeacherAdapter
    private val dataList: MutableList<ProcessLists> = mutableListOf()
    //初始化列表
    private fun initRecyclerView() {
        rv_list.isNestedScrollingEnabled = false
        mAdapter = POrderTeacherAdapter(dataList, context)
        rv_list.adapter = mAdapter
        rv_list.layoutManager = LinearLayoutManager(context)
        mAdapter.setOnTypeClickListener { obj, position, flag ->
            if (flag == ITEM_CLICK) {//
            }
        }
    }


    override fun closeMvp() {
    }

}
